<template>
  <tbody v-if="pivotData">
    <template v-if="groupMode === 'default'">
      <VPivottableBodyRows
        :row-keys="rowKeys"
        :col-keys="colKeys"
        :row-total="rowTotal"
        :table-options="tableOptions"
        :groupMode="groupMode"
      />
    </template>
    <IBizGroupPivotTableBody v-else :groupData="groupData" :rowKeys="rowKeys" :colKeys="colKeys" :rowAttrs="rowAttrs" />
    <VPivottableBodyRowsTotalRow
      :col-total="colTotal"
      :row-total="rowTotal"
      :row-attrs="rowAttrs"
      :col-attrs="colAttrs"
      :col-keys="colKeys"
      :localeStrings="localeStrings"
      :table-options="tableOptions"
    />
  </tbody>
</template>

<script setup>
import { useProvidePivotData } from '@/pivottable/composables/useProvidePivotData'
import VPivottableBodyRows from './VPivottableBodyRows.vue'
import VPivottableBodyRowsTotalRow from './VPivottableBodyRowsTotalRow.vue'

const props = defineProps({
  rowTotal: {
    type: Boolean,
    default: true
  },
  colTotal: {
    type: Boolean,
    default: true
  },
  localeStrings: {
    type: Object,
  },
  tableOptions: {
    type: Object,
    default: () => ({
      clickCallback: null
    })
  },
  groupMode: {
    type: String,
    default: 'default'
  }
})

const { pivotData, rowKeys, colKeys, rowAttrs, colAttrs, getAggregator, groupData } =
  useProvidePivotData();

</script>
